/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jifConsultarIngresos.java
 *
 * Created on 02-ago-2010, 11:04:23
 */

package GestionMovimientos;

import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.Listas;
import administracion.helper.MiTablePrint;
import administracion.helper.Utiles_Cadena;
import administracion.helper.Utiles_Fecha;
import administracion.helper.Utiles_MensajesDialogo;
import administracion.helper.Utiles_Tabla;
import administracion.helper.jPaginacion;
import com.jidesoft.hints.ListDataIntelliHints;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.ELProperty;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;
import suministros.ejb30.TO.CentroCostoTO;
import suministros.ejb30.TO.DetalleIngresoTO;
import suministros.ejb30.TO.DetalleTransferenciaTO;
import suministros.ejb30.TO.EmpresaTO;
import suministros.ejb30.TO.IngresoTO;
import suministros.ejb30.TO.ProyectoTO;
import suministros.ejb30.TO.TipoTO;
import suministros.ejb30.TO.TransferenciaTO;
import suministros.ejb30.TO.UnidadOrganizativaTO;
import suministros.ejb30.entity.CentroCosto;
import suministros.ejb30.entity.DetalleMovimiento;
import suministros.ejb30.entity.Movimiento;
import suministros.ejb30.entity.Proyecto;
import suministros.ejb30.entity.Tipo;
import suministros.ejb30.entity.UnidadOrganizativa;
import suministros.ejb30.helper.Utiles_Convertir;

/**
 *
 * @author Diana
 */
public class jifConsultarSalidas extends javax.swing.JInternalFrame implements Observer{
    Movimiento mov;
    List<IngresoTO> detalles=new ArrayList<IngresoTO>();
    private JTableBinding jTableBinding;
    List listaTipos = null;
    List<EmpresaTO> empresas;
    private  jPaginacion panelPaginacion;
    /** Creates new form jifConsultarIngresos */
    public jifConsultarSalidas() {
        this.panelPaginacion = new jPaginacion(this,15);
        initComponents();
        empresas = Listas.getEmpresas();
        if(empresas.isEmpty()){
            this.jCheckBox1.setEnabled(false);
        }
        llenarComboTipoSalida();
        llenarComboTipoMovimiento();
        this.jCheckBox1.setSelected(false);
        this.llenarComboEmpresa();
       
        this.jbtBuscar.requestFocus();
        this.jcbEmpresa1.setEnabled(false);
    }
    private void llenarComboEmpresa() {
        
        empresas = null;
        List listaPaises_cbo = this.cboBeanBindingEmpresa1.getLista();
        listaPaises_cbo.clear();
        try
        {
          if(this.jCheckBox1.isSelected()){
                empresas = Listas.getEmpresas();
            }
            else{
                empresas = Listas.getEmpresaPrincipal();
            }
          this.cboBeanBindingEmpresa1.setLista(empresas);
          this.bindingGroup.bind();
          this.jcbEmpresa1.updateUI();
          this.jcbEmpresa1.setSelectedIndex(0);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener empresas\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifIngresosAlmacen.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    private void llenarComboTipoSalida() {
        List listaTipos2 = null;
        List listaTipos_cbo2 = this.cboBeanBindingTipo2.getLista();
        listaTipos_cbo2.clear();
        try
        {
          listaTipos2 = Listas.getTipo_porTabla("Tipo_Salida");

          this.cboBeanBindingTipo2.setLista(listaTipos2);
          this.bindingGroup.bind();
          this.jcbTipoIngreso.updateUI();
          this.jcbTipoIngreso.setSelectedIndex(-1);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Ingresos\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifIngresosAlmacen.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
     private void llenarComboTipoMovimiento() {

        List listaTipos_cbo = this.cboBeanBindingTipo1.getLista();
        listaTipos_cbo.clear();
        try
        {
         listaTipos = Listas.getTipo_porTabla("tipo_Movimiento");

        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener tipos documentos\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifIngresosAlmacen.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
  
     private void obtenerDetallesIngreso(int tipo) {
       Tipo t=Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.listaTipos.get(1));
       Tipo ti=Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.jcbTipoIngreso.getSelectedItem());
       String  emp=empresas.get(this.jcbEmpresa1.getSelectedIndex()).getCodigo();
       int mes= Utiles_Cadena.getMesAnioT(this.jcbMes.getSelectedItem().toString().trim());
       String ano= this.jtfAnio.getText().toString();
       try{
           if(tipo==1){
            this.detalles = GestionPedidosDelegate.getInstance().getDatosMovimiento(this.jtfIngreso.getText().trim(), t.getIdTablaTipo(),1,"","",ti.getIdTablaTipo(), emp,ano, mes,this.panelPaginacion.getPagActual(),this.panelPaginacion.getPagTamano());
           }
          
           if(tipo==6){
            this.detalles = GestionPedidosDelegate.getInstance().getDatosMovimiento("", t.getIdTablaTipo(),6,"","",ti.getIdTablaTipo(), emp,ano, mes,this.panelPaginacion.getPagActual(),this.panelPaginacion.getPagTamano());
           }

        }
         catch (Exception ex) {
            Logger.getLogger(jifIngresosAlmacen.class.getName()).log(Level.SEVERE, null, ex);
        }
       
       if(detalles.isEmpty()){
            Utiles_MensajesDialogo.mensajeAlerta("No se han encontrado detalles salidas de almacen");
      }
      //cargarDatos();

  }
      private int obtenerDetallesIngresoTamaño(int tipo) {
       Tipo t=Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.listaTipos.get(1));
       Tipo ti=Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.jcbTipoIngreso.getSelectedItem());
       String  emp=empresas.get(this.jcbEmpresa1.getSelectedIndex()).getCodigo();
       int mes= Utiles_Cadena.getMesAnioT(this.jcbMes.getSelectedItem().toString().trim());
       String ano= this.jtfAnio.getText().toString();
       int tamaño=0;
       try{
           if(tipo==1){
            tamaño = GestionPedidosDelegate.getInstance().getDatosMovimientoTamaño(this.jtfIngreso.getText().trim(), t.getIdTablaTipo(),1,"","",ti.getIdTablaTipo(), emp,  ano,mes);
           }

           if(tipo==6){
             tamaño = GestionPedidosDelegate.getInstance().getDatosMovimientoTamaño("", t.getIdTablaTipo(),6,"","",ti.getIdTablaTipo(), emp,ano,mes);
           }
      }
        catch (Exception ex) {
            Logger.getLogger(jifIngresosAlmacen.class.getName()).log(Level.SEVERE, null, ex);
        }
       return tamaño;
     }
     public void cargarDatos(){
    this.bindingGroup = new BindingGroup();
    this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, this.detalles, this.jtDetalleSuministro);

    JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${idmovimiento}"));

    columnBinding0.setColumnName("Codigo");
    columnBinding0.setColumnClass(String.class);
    columnBinding0.setEditable(false);

    JTableBinding.ColumnBinding columnBinding1 = this.jTableBinding.addColumnBinding(ELProperty.create("${tipoIngreso}"));

    columnBinding1.setColumnName("Tip.Ingreso");
    columnBinding1.setColumnClass(String.class);
    columnBinding1.setEditable(false);

    JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${fecha}"));

    columnBinding2.setColumnName("Fecha");
    columnBinding2.setColumnClass(String.class);
    columnBinding2.setEditable(false);

    JTableBinding.ColumnBinding columnBinding3 = this.jTableBinding.addColumnBinding(ELProperty.create("${almacen}"));

    columnBinding3.setColumnName("Almacen");
    columnBinding3.setColumnClass(String.class);
    columnBinding3.setEditable(false);

    JTableBinding.ColumnBinding columnBinding5 = this.jTableBinding.addColumnBinding(ELProperty.create("${cod_pedido}"));

    columnBinding5.setColumnName("Pedido");
    columnBinding5.setColumnClass(String.class);
    columnBinding5.setEditable(true);


    JTableBinding.ColumnBinding columnBinding7 = this.jTableBinding.addColumnBinding(ELProperty.create("${tipoDocumento}"));

    columnBinding7.setColumnName("Serie");
    columnBinding7.setColumnClass(String.class);
    columnBinding7.setEditable(true);

    JTableBinding.ColumnBinding columnBinding8 = this.jTableBinding.addColumnBinding(ELProperty.create("${nroDocumento}"));

    columnBinding8.setColumnName("Numero");
    columnBinding8.setColumnClass(String.class);
    columnBinding8.setEditable(true);

    this.bindingGroup.addBinding(this.jTableBinding);
    this.bindingGroup.bind();
    //MiTablePrint.autoSizeTableColumns(jtDetalleSuministro);
    try {
          int[] porcentajes= {15,15,10,15,15,15,15};
          Utiles_Tabla.definirAnchoColumnasJTable(jtDetalleSuministro, porcentajes);
          // MiTablePrint.autoSizeTableColumns(jtDetalleSuministro);
        } catch (Exception ex) {
            Logger.getLogger(jifConsultarIngresos.class.getName()).log(Level.SEVERE, null, ex);
        }

    
  }
     
     
      
     public void GenerarReporte(String codigo){
        JasperViewer jv = null;
        JasperPrint jp = null;
        Map parametros = new HashMap();
        parametros.put("idMovimiento", codigo);
        try {
            jp=GestionPedidosDelegate.getInstance().generarReporteIngreso("NotaSalidaFLP.jasper", parametros);
            jv = new JasperViewer(jp, false);
            jv.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH);
            jv.setVisible(true);
        }catch (Exception e) {
            Utiles_MensajesDialogo.mensajeError("No se pudo realizar la transaccion");
        }


  }
     public void GenerarReporteTrans(String codigo){
        JasperViewer jv = null;
        JasperPrint jp = null;
        Map parametros = new HashMap();
        parametros.put("idMovimiento", codigo);
        try {
            jp=GestionPedidosDelegate.getInstance().generarReporteIngreso("NotaSalidaFLP.jasper", parametros);
            jv = new JasperViewer(jp, false);
            jv.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH);
            jv.setVisible(true);
        }catch (Exception e) {
            Utiles_MensajesDialogo.mensajeError("No se pudo realizar la transaccion");
        }
  }
   public void consultar(){
       if(this.jcbEmpresa1.getSelectedIndex()>=0){
        if(this.jcbTipoIngreso.getSelectedIndex()>=0){
        if(this.jtfIngreso.getText().trim().length() > 0){
              this.obtenerDetallesIngreso(1);
        }
        else{
              this.obtenerDetallesIngreso(6);
          }
        }
        else{
             Utiles_MensajesDialogo.mensajeError("No se ha seleccionado un tipo de ingreso");
        }
        }
        else{
             Utiles_MensajesDialogo.mensajeError("No se ha seleccionado ni ninguna empresa");
    }
   }
 public int consultarTamaño(){
      int tamaño=0;
       if(this.jcbEmpresa1.getSelectedIndex()>=0){
        if(this.jcbTipoIngreso.getSelectedIndex()>=0){
        if(this.jtfIngreso.getText().trim().length() > 0){
              tamaño=this.obtenerDetallesIngresoTamaño(1);
        }
        else{
              tamaño=this.obtenerDetallesIngresoTamaño(6);
          }
        }
        else{
             Utiles_MensajesDialogo.mensajeError("No se ha seleccionado un tipo de ingreso");
        }
        }
        else{
             Utiles_MensajesDialogo.mensajeError("No se ha seleccionado ni ninguna empresa");
    }
      return tamaño;
   }
    public void buscar(){
       try
        {
           int num_ordenes_encontradas =consultarTamaño();
           panelPaginacion.setTotalResultados(num_ordenes_encontradas);
        }
        catch (Exception e) {
            Utiles_MensajesDialogo.mensajeError(e.getMessage());
        }
  }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        cboBeanBindingTipo1 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingTipo2 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingEmpresa1 = new administracion.BeanBinding.CboBeanBindingEmpresa();
        jLabel1 = new javax.swing.JLabel();
        jtfIngreso = new javax.swing.JTextField();
        jbtVer = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jbtBuscar = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        jcbTipoIngreso = new javax.swing.JComboBox();
        jcbEmpresa1 = new javax.swing.JComboBox();
        jbtImprimir = new javax.swing.JButton();
        jCheckBox1 = new javax.swing.JCheckBox();
        jbtDetalles = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jtfAnio = new javax.swing.JTextField();
        jcbMes = new javax.swing.JComboBox();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtDetalleSuministro = new javax.swing.JTable();
        this.jtDetalleSuministro.getTableHeader().setReorderingAllowed(false) ;

        setForeground(java.awt.Color.white);
        setIconifiable(true);
        setTitle("CONSULTAR SALIDAS DE ALMACEN");

        jLabel1.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel1.setText("NOTA DE SALIDA:");

        jtfIngreso.setFont(new java.awt.Font("Arial", 0, 12));
        jtfIngreso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfIngresoActionPerformed(evt);
            }
        });
        jtfIngreso.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfIngresoKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfIngresoKeyReleased(evt);
            }
        });

        jbtVer.setFont(new java.awt.Font("Arial", 1, 12));
        jbtVer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/view_text.png"))); // NOI18N
        jbtVer.setMnemonic('V');
        jbtVer.setText("VER NOTA");
        jbtVer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtVerActionPerformed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jButton2.setMnemonic('C');
        jButton2.setText("CERRAR");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jbtBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/find.png"))); // NOI18N
        jbtBuscar.setText("Buscar");
        jbtBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtBuscarActionPerformed(evt);
            }
        });
        jbtBuscar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbtBuscarKeyPressed(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel11.setText("TIPO SALIDA:");

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingTipo2, eLProperty, jcbTipoIngreso);
        bindingGroup.addBinding(jComboBoxBinding);

        jcbTipoIngreso.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcbTipoIngresoItemStateChanged(evt);
            }
        });
        jcbTipoIngreso.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcbTipoIngresoKeyPressed(evt);
            }
        });

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingEmpresa1, eLProperty, jcbEmpresa1);
        bindingGroup.addBinding(jComboBoxBinding);

        jcbEmpresa1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcbEmpresa1KeyPressed(evt);
            }
        });

        jbtImprimir.setFont(new java.awt.Font("Arial", 1, 12));
        jbtImprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/document_print.png"))); // NOI18N
        jbtImprimir.setText("IMPRIMIR");
        jbtImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtImprimirActionPerformed(evt);
            }
        });
        jbtImprimir.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbtImprimirKeyPressed(evt);
            }
        });

        jCheckBox1.setFont(new java.awt.Font("Arial", 1, 12));
        jCheckBox1.setText("OTRAS EMPRESAS");
        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox1ActionPerformed(evt);
            }
        });

        jbtDetalles.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jbtDetalles.setText("DETALLES");
        jbtDetalles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtDetallesActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel2.setText("AÑO:");

        jLabel3.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel3.setText("MES:");

        jcbMes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ENERO", "FEBRERO", "MARZO", "ABRIL", "MAYO", "JUNIO", "JULIO", "AGOSTO", "SETIEMBRE", "OCTUBRE", "NOVIEMBRE", "DICIEMBRE" }));

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Movimientos Encontrados", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(0, 0, 255))); // NOI18N
        jPanel1.setLayout(new java.awt.BorderLayout());
        jPanel1.add(panelPaginacion,BorderLayout.NORTH);

        jtDetalleSuministro.setFont(new java.awt.Font("Arial", 0, 12));
        jtDetalleSuministro.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Codigo", "Tipo Ingreso", "Fecha", "Almacen", "Ubicacion", "NroOrden", "CodTransferencia"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane2.setViewportView(jtDetalleSuministro);

        jPanel1.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(9, 9, 9)
                .addComponent(jCheckBox1)
                .addGap(6, 6, 6)
                .addComponent(jcbEmpresa1, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addComponent(jLabel11)
                .addGap(57, 57, 57)
                .addComponent(jcbTipoIngreso, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28)
                .addComponent(jLabel1)
                .addGap(10, 10, 10)
                .addComponent(jtfIngreso, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addComponent(jLabel2)
                .addGap(10, 10, 10)
                .addComponent(jtfAnio, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(47, 47, 47)
                .addComponent(jLabel3)
                .addGap(10, 10, 10)
                .addComponent(jcbMes, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jbtBuscar))
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 666, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(159, Short.MAX_VALUE)
                .addComponent(jbtVer)
                .addGap(10, 10, 10)
                .addComponent(jbtImprimir)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbtDetalles)
                .addGap(84, 84, 84)
                .addComponent(jButton2)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCheckBox1)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jcbEmpresa1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(5, 5, 5)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addComponent(jLabel11))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jcbTipoIngreso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel1))
                    .addComponent(jtfIngreso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jtfAnio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel3))
                    .addComponent(jcbMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addComponent(jbtBuscar)
                .addGap(6, 6, 6)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jbtVer)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jbtImprimir)
                        .addComponent(jbtDetalles, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButton2))
                .addContainerGap())
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jtfIngresoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfIngresoKeyReleased
       
    }//GEN-LAST:event_jtfIngresoKeyReleased

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
         int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de salir?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){
            this.dispose();
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jtfIngresoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfIngresoKeyPressed
         
      
    }//GEN-LAST:event_jtfIngresoKeyPressed

    private void jbtBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtBuscarActionPerformed
    buscar();
       


}//GEN-LAST:event_jbtBuscarActionPerformed

    private void jtfIngresoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfIngresoActionPerformed

        this.detalles.clear();
        this.jtfIngreso.setText("");
        this.cargarDatos();
    }//GEN-LAST:event_jtfIngresoActionPerformed

    private void jbtVerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtVerActionPerformed
       try {
           int fila =this.jtDetalleSuministro.getSelectedRow() ;
            if (fila < 0) {
                Utiles_MensajesDialogo.mensajeError("Debe elegir una nota de ingreso");
                return;
            }else{
               if(jtDetalleSuministro.getValueAt(fila, 6).toString().compareTo("")==0){
                   GenerarReporte(jtDetalleSuministro.getValueAt(fila, 0).toString());
               }
               else{
                   GenerarReporteTrans(jtDetalleSuministro.getValueAt(fila, 0).toString());
               }
   
            }
  
        } catch (Exception e) {
            e.printStackTrace();
        }


    }//GEN-LAST:event_jbtVerActionPerformed

    private void jbtBuscarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbtBuscarKeyPressed
         if(KeyEvent.VK_ENTER == evt.getKeyCode() ||KeyEvent.VK_TAB == evt.getKeyCode()  ){
             this.jbtBuscar.doClick();
         }
    }//GEN-LAST:event_jbtBuscarKeyPressed

    private void jcbTipoIngresoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcbTipoIngresoKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jtfIngreso.requestFocus();
        }
}//GEN-LAST:event_jcbTipoIngresoKeyPressed

    private void jcbTipoIngresoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcbTipoIngresoItemStateChanged

        this.detalles.clear();
        this.jtfIngreso.setText("");
        this.cargarDatos();
    }//GEN-LAST:event_jcbTipoIngresoItemStateChanged

    private void jcbEmpresa1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcbEmpresa1KeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            if(this.jcbEmpresa1.getSelectedIndex()>=0){
                this.jcbTipoIngreso.requestFocus();
            }
        }
}//GEN-LAST:event_jcbEmpresa1KeyPressed

    private void jbtImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtImprimirActionPerformed

         MiTablePrint pp = new MiTablePrint(this.jtDetalleSuministro, "LISTADO DE NOTAS DE SALIDA", "LISTADO DE NOTAS DE SALIDA DEL ALMACEN");
        pp.showPrintPreview();
}//GEN-LAST:event_jbtImprimirActionPerformed

    private void jbtImprimirKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbtImprimirKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbtImprimir.doClick();
        }
}//GEN-LAST:event_jbtImprimirKeyPressed

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
        if(this.jCheckBox1.isSelected()){
            this.jcbEmpresa1.setEnabled(true);
        } else{
            this.jcbEmpresa1.setEnabled(false);
        }
        this.llenarComboEmpresa();
      
}//GEN-LAST:event_jCheckBox1ActionPerformed

    private void jbtDetallesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtDetallesActionPerformed
          int fila=this.jtDetalleSuministro.getSelectedRow();
        if(fila>=0){
            String codigo=this.jtDetalleSuministro.getValueAt(fila, 0).toString();
            Frame frm = JOptionPane.getFrameForComponent((JInternalFrame)this);
            jdAdministrarMovimientosSalidas panel = new jdAdministrarMovimientosSalidas(frm,this,true,codigo,1);
            panel.setLocationRelativeTo(null);
            panel.setVisible(true);
        }
        else{
             Utiles_MensajesDialogo.mensajeError("Debe elegir una nota de ingreso");
        }
    }//GEN-LAST:event_jbtDetallesActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private administracion.BeanBinding.CboBeanBindingEmpresa cboBeanBindingEmpresa1;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo1;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo2;
    private javax.swing.JButton jButton2;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JButton jbtBuscar;
    private javax.swing.JButton jbtDetalles;
    private javax.swing.JButton jbtImprimir;
    private javax.swing.JButton jbtVer;
    private javax.swing.JComboBox jcbEmpresa1;
    private javax.swing.JComboBox jcbMes;
    private javax.swing.JComboBox jcbTipoIngreso;
    private javax.swing.JTable jtDetalleSuministro;
    private javax.swing.JTextField jtfAnio;
    private javax.swing.JTextField jtfIngreso;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    public void update(Observable o, Object arg) {
        consultar();
        this.cargarDatos();
    }

}
